#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int main()
{
    int X = 0;
    int N = 0;
    scanf("%d%d", &X, &N);
    printf("%d\n", (X + N - 1) % 7 + 1);

    return 0;
}